package com.hudson.plugin.result.collector.server.router;

import org.apache.camel.CamelExecutionException;
import org.apache.camel.test.junit4.CamelSpringTestSupport;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Map;
import java.util.concurrent.Future;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 4/26/11
 * Time: 7:14 PM
 * To change this template use File | Settings | File Templates.
 */

public class RouterDebugger extends CamelSpringTestSupport {
    private final static String json = "{\"CCheck\":" +
            "{\"GetScore\":\"65.8466\",\"GetSummary\":\"CCheck Check Result:<a href=\\\"ccheckResult\\\">1 warning</a> from one CCheck file.\"," +
            "\"GetResult\":null,\"GetDetails\":\"\",\"GetDisplayName\":\"CCheck code analyse report\"},\"commonValuePairs\":{\"result\":\"SUCCESS\"," +
            "\"slave\":\"[master]\",\"build_data\":\"2011-04-29 19:10:30\",\"projectUrl\":\"job/test/\",\"skipCount\":\"0\"," +
            "\"failCount\":\"0\",\"duration\":\"43794\",\"totalCount\":\"0\",\"cause_action\":\"UserCause\"," +
            "\"build_num\":\"39\",\"build_on\":\"localhost\",\"hudsonUrl\":\"http://localhost:8080/\",\"cause_action_user\":\"anonymous\"," +
            "\"projectName\":\"test\"}}";

    @Override
    protected AbstractApplicationContext createApplicationContext() {
        return new ClassPathXmlApplicationContext("/META-INF/spring/bundle-context.xml");
    }

    @Test
    public void testOSGiRoute() throws Exception {
        Future<Map> future = template.asyncRequestBody("jms:queue:xmlBody", json, Map.class);
        try {
            Map<String, String> result = future.get();
            result.get("");
        } catch (CamelExecutionException exception) {

        }


        assertTrue(true);
    }
}
